<!DOCTYPE html>
<html> 
<head> 
    <meta charset="UTF-8"> 
    <title></title> 
</head> 
<body> 
<script src="http://oss.sheetjs.com/js-xlsx/xlsx.full.min.js"></script> 
<script> 
    //如果使用 FileSaver.js 就不要同时使用以下函数 
    function saveAs(obj, fileName) {
        //当然可以自定义简单的下载文件实现方式 
        var tmpa = document.createElement("a"); 
        tmpa.download = fileName || "下载"; 
        tmpa.href = URL.createObjectURL(obj); //绑定a标签 
        tmpa.click(); //模拟点击实现下载 
        setTimeout(function () { //延时释放 
            URL.revokeObjectURL(obj); //用URL.revokeObjectURL()来释放这个object URL 
        }, 100); 
    } 
    var json = [{ //测试数据 
        "分组": 1,//A 
        "所属公司": "aa",
        "参赛人员": "bb"
    }, { 
        "分组": 2, 
        "所属公司": "cc", 
        "参赛人员": "dd"
    }, { 
        "分组": 3, 
        "所属公司": "ee", 
        "参赛人员": "ff"
    }];

    const wopts = { bookType: 'xlsx', bookSST: true, type: 'binary' };//这里的数据是用来定义导出的格式类型 
    function downloadExl(type) {
        var wb = { SheetNames: ['Sheet1'], Sheets: {}, Props: {} }; 
        //wb.Sheets['Sheet1'] = XLSX.utils.json_to_sheet(json);//通过json_to_sheet转成单页(Sheet)数据 
        json = XLSX.utils.json_to_sheet(json); 
        json["A2"] = { t: "s", v: "A组" }; 
        json["!merges"] = [{//合并第一列数据[A2,A3,A4,A5] 
            s: {//s为开始 
                c: 0,//开始列 
                r: 1//开始行
            }, e: {//e结束 
                c: 0,//结束列 
                r: 4//结束行
            } 
        }]; 
        wb.Sheets['Sheet1'] = json; 
        saveAs(
        new Blob([s2ab(XLSX.write(wb, wopts))], { type: "application/octet-stream"}), 
        "这里是下载的文件名" + '.' + (wopts.bookType == "biff2" ? "xls" : wopts.bookType)); 
    } 
    function s2ab(s) { 
        if (typeof ArrayBuffer !== 'undefined') { 
            var buf = new ArrayBuffer(s.length); 
            var view = new Uint8Array(buf); 
            for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF; 
            return buf; 
        } else { 
            var buf = new Array(s.length); 
            for (var i = 0; i != s.length; ++i) buf[i] = s.charCodeAt(i) & 0xFF; 
            return buf; 
        } 
    } 
</script> 
<button onclick="downloadExl()">导出</button> 
</body> 
</html>